Back in the days of horses and carriages, wheels were attached to the carriage by way of a wooden or metal stick axle that was fixed to the carriage, requiring the wheels to rotate on the axle. A major drawback of this setup was that there was a lot of friction between the wheel and the axle, and that friction made it harder to move the carriage, resulting in wasted energy. The other issue was that the friction would cause a lot of wear and tear on the axle and wheel where they joined, so you'd need to do constant maintenance on the joint.
The first caged bearings for axles were patented in the late 1700s, and the design that has carried forward to modern times is basically a set of steel balls or rollers that are housed within a ring-shaped housing called a race. Most ball bearings will have an inner race, which is grooved and holds the balls on the inside, and a grooved outer race on the outer circumference of the bearing. In a roller bearing, the race has slots that allow the rollers to spin against the axle on the inside and the wheel on the outside.
In automotive applications, the wheel bearings are usually sealed units that connect the wheel to the suspension of the vehicle. Your wheel studs will typically be part of the bearing and if it is a drive wheel, there can be a hollow in the middle of the bearing where a spindle is inserted from the axle shaft.