Often my group stands in a line and fire ranged attacks through each others' square to attack enemies ahead. Are there any rules for this, can ranged attacks like arrows and area-of-effect attacks harm allies?
Allies have, by default, absolutely no impact on ranged attacks against your enemies. If an attack targets one creature, it targets one creature, without hurting your allies in between.
Area of effect attacks are a different matter. If the attack targets each creature (as opposed to each enemy) in the area, then your allies are targeted as well and must face the attack roll like the enemies.
As for possible effects on targeting, see Player's Handbook 1, page 280, on rules of cover and concealment:
As a related note, I've always considered bonuses like Ranger's Prime Shot that grant bonuses for being the closest to the target to represent the liberty you have when not having to worry about hitting your team-mates (in-universe).
In D&D 4e allies are supposed to move in their square in a way that does not hamper your line of fire.
Area of Effect spells only need line of effect between you and the source of your Burst and from the Burst source to the target (PHB p.272). Not even enemies or obstacles can provide cover bonuses, so allies are not an exception.