Yes, it can
First of all, a carpet that is animated by animate objects can, in fact, fly:
Its speed is 30 feet, if the objects lack legs or other appendages it can use for locomotion, it instead has a flying speed of 30 feet and can hover.
A carpet has no appendages to use for locomotion, so it gets a flying speed of 30 feet.
Next, how much it can carry and still fly; this depends on its Strength.
Carrying Capacity. Your carrying capacity is your Strength score multiplied by 15. This is the weight (in pounds) that you can carry, which is high enough that most characters don't usually have to worry about it.
This is then further changed by their size category.
So what strength does your animated carpet have? Well, it depends on how big it is, as determined by your DM:
Tiny - HP: 20, AC: 18, Attack: +8 to hit, 1d4 + 4 damage, Str: 4, Dex: 18
Carries 30 lbs.
Small - HP: 25, AC: 16, Attack: +6 to hit, 1d8 + 2 damage, Str: 6, Dex: 14
Carries 90 lbs.
Medium - HP: 40, AC: 13, Attack: +5 to hit, 2d6 + 1 damage, Str: 10, Dex: 12
Carries 150 lbs.
Large - HP: 50, AC: 10, Attack: +6 to hit, 2d10 + 2 damage, Str: 14, Dex: 10
Carries 420 lbs.
Huge - HP: 80, AC: 10, Attack: +8 to hit, 2d12 + 4 damage, Str: 18, Dex: 6
Carries 960 lbs.
A suitably large animated carpet should be able to carry roughly one, maybe two, people and their equipment, if they're not particularly heavy and don't carry a lot of gear.