A bearing is an interface that enables the axle to rotate inside some fixed part. The axle rolls on the bearings. For example, consider your hubs, pedals, the cranks, and your front fork.
Sheldon Brown has a longer discussion on bearings. Most bearings are steel balls.
Preload is important term related to bearings. For your hubs, preload is how much the hub is getting squeezed in from the side, ignoring the quick release skewer. All cup and cone hubs have inherent preload adjustment, but not all cartridge bearing hubs or other devices do. Too much preload will make the bearings grind and wear out. Too little preload can leave play in the hub (i.e. side to side movement when the quick release skewer is clamped) or other device (e.g. crankset, headset will rock back and forth).
Bearings will feel gritty when they are worn or dirty. You can feel this by spinning the wheel in your hand, holding near the axles, or otherwise working the component by hand. In some cases, e.g. you submerged the bike during a river crossing, you can wash out the grease from the bearing, and cause it to sound dry (a whirring sound) but not feel gritty. If the bearing feels notchy or indexed, this can mean too much preload, or that the bearing bore is not round (e.g. it's been ovalized).
Cup and cone bearings
This type of bearing, pictured above, has the balls rotating between the cup and the cone. The locknut tightens the assembly together, and can be loosened with a standard sized wrench.
Cup and cone bearings require periodic service. Service involves cleaning out the old grease, which may have had some dirt mixed in with it, and adding fresh grease. If the balls are worn, you can measure their size with a caliper and buy replacements. Alternatively, manufacturers' technical documentation will frequently state the size and number of ball bearings; take note that sizes for front and rear hubs may be different. Eventually, the cones should wear, and manufacturers should maintain these as replacement parts as well. The cups may not be replaceable, as they are frequently integrated into the hub or pressed in extremely tightly.
Cup and cone bearings are more traditional and are frequently present on older equipment, but some companies persist in making high-quality cup and cone bearings (notably Shimano and Campagnolo).
Cup and cone hubs all require preload adjustment. Best practice is to tighten the locknuts so that there is barely perceptible play when the hub is off the bike, and zero play when the quick release or thru axle is tightened. Some cartridge bearing hubs require preload adjustment.
Most manufacturers have moved to cartridge bearings. In many contexts, cartridges are sealed units that can contain things like printer ink, film, or, in bicycles, ball bearings, seals, and races (roughly equivalent to the cone and the cup respectively). Sometimes they are called sealed cartridge bearings, and most of the bearings in bicycles have rubber seals, but this is potentially a misnomer. Bicycle bearings might be unshielded at one end, and cup and cone bearings can have seals built in.
To replace cartridge bearings, you will need a bearing extractor to pull or push the bearing out, and a bearing press to push it back in. Related to presses, bearing drifts help align the bearings as they are going in. Bike stores frequently have these items. As a makeshift replacement for a bearing press, you can use a block of wood and a hammer, but you need to visually confirm the bearing is going in straight. For bearing extraction, you can use a screwdriver or chisel and a hammer, and carefully hammer the bearing out. Both procedures may damage the bearing seat, however.
The bearings themselves are available commercially from many suppliers. A competent mechanic will know how to measure the bearing size. However, measuring the outer diameter, inner diameter, and depth are often sufficient to give you a bearing size. Bearings are commonly sold by coded numbers, which correspond to size. For example 6806 bearings are common in rear hubs. They have a 42mm outer diameter, 30mm inner diameter, and are 7mm deep.
Bearings are sealed to keep contaminants out. Contaminants would wear the balls or races out. Most bicycle bearings have rubber seals on both sides, but other arrangements exist. If uncertain, check with a mechanic.
Most cartridge bearings are designed not to be serviced. Just replace them when worn. Some higher-end manufacturers (e.g. Chris King, Kogel) design their bearings to be serviced periodically. This entails gently removing the rubber seals, cleaning the grease, and adding fresh grease. If there are no specific instructions, assume that there is no need to service the bearing.
Many factors may influence the durability of the bearing. If you ride in wet conditions, this will reduce durability. If you pressure wash your bike, take care not to point the hose straight at the bearings (in your hubs, bottom bracket, rear suspension pivot). As stated earlier, some bearings are more tightly sealed than others, trading off higher friction.
In a press fit bottom bracket, if the bottom bracket seats are not parallel to each other or if one is out of round, that can damage the BB over time. Bearings also have a load capacity. If a piece of equipment was designed with bearings that are too small to take the loads applied to it, that would also impact bearing life. Additionally, all else equal, the more narrowly spaced the bearings are, the higher the loads on them will be. This does affect some press fit standards, like BB30 and PF30, which have their bearings more narrowly spaced than others. Last, the material quality of bearings and the races they run on has an impact. This would include the specific steel alloys used as well as their pureness, and how smooth they are.
Ceramic bearings are sometimes offered as an upgrade on high-end bikes. They have marginally lower rolling resistance than high-quality steel ball bearings. In many industrial applications, ceramic bearings are thought to be more durable, but this may or may not transfer to bicycling applications. In addition, ceramic bearings are extremely hard, and they must be paired with a high-quality steel race, or else they can dent the race when the bike goes over bumps. Many cheap ceramic bearings may skimp on the quality of the races, and buyers should beware.
Bushings (link to Wikipedia) are another form of bearing. These involve a sleeve rotating over the axle. Bushings are often used in rear derailer jockey wheels and in mountain bike suspension.