The system has changed several times since it was introduced, but the basic system has been mostly the same since Platinum/HeartGold/SoulSilver(not Diamond/Pearl).
The parents must be of opposite genders and have a matching Egg Group - every Pokemon belongs to one or two Egg Groups, and the parents must match. Anything with the "Undiscovered" Egg Group(except Ditto) are sterile - typically legendary and "baby"(Togepi, Happiny) Pokemon. Alternately, one parent can be a Ditto. The species of the offspring is the same as the female, unless the "mother" is Ditto, then it's the father's species(this is the only way to breed male-only Pokemon like Tauros).
Stat inheritance works as follows: IVs for 3 stats are picked randomly, and the parent each of those 3 stats are also coin-flipped. For example, it may pick Attack, Sp. Defense, and Speed, then pick to inherit the Attack IV from Dad and the other two IVs from Mom. This occurs if the parents are not holding specific items, mainly the EV-gain boosting items: Power Weight/Belt/Bracer/Band/Lens/Anklet(NOT Macho Brace). If one holds one of those, the baby will inherit the corresponding stat from that parent, then 2 random stats from the parents(coin-flipping which parent). If BOTH parents hold a Power item, then ONE of the parents are picked to transfer the stat corresponding to their held item, then 2 random stats from random parents. Example: Mom holds Power Weight(HP), Dad holds Power Lens(Sp.Atk), then the baby is guaranteed to inherit EITHER Mom's HP IV, or Dad's Sp.Atk IV, then two other stats are picked at random and Mom and Dad coin-flip over who gives those two random stats.
Another held item to consider is the Destiny Knot, which causes 5 stats to be picked instead of 3. If the Destiny Knot is used with a Power item, the guaranteed inherit will be one of the 5(so one guaranteed, 4 random).
Bulbapedia page for breeding.