My obgyn prescribed me labetalol. I'm 24 weeks pregnant how will this pills affect my unborn baby?

Safe. High blood pressure is very dangerous in pregnancy leading to poor fetal growth, placenta abruption and even death. Controlling high blood pressure is extremely important. Labetolol and methyl dopa are the 2 most common blood pressure meds for pregnant women. Labetolol works well. It can cause issues with amniotic fluid levels so ultrasounds are usually done to monitor.
Benefit > risk. Many medications like Labetalol are given in situations where the condition (hypertension) is well known to have adverse effects on the pregnancy. >risk of fetal loss, speeding the placental breakdown, >risk of premi delivery, producing kidney damage, risk of stroke, etc. Existing data show it relatively safe. In such a situation drs pick a med based on best help/risk profile. Discuss with your dr.