When does one usually use this phrase? When greeting other people? Is it more formal than مرحباً?
As formality yes, and it is generally deemed better and in fact used more often than Marhaban. However, we usually say "Salám" only without the lengthy one here - probably they are aiming on longer sentences to teach you something here.