**The advice provided below is not legal or medical advise. You should consult with a tax or benefits professional always. The advice provided below is simply our experience and the information that we discovered after the loss of our child. It might be helpful or relevant to you, but it also might not be.**
Taxes
If your baby was born living (has a birth certificate) and you signed up for a social security number you can claim them on your taxes, no matter how long they lived for. You'll be eligible for the Child Tax Credit for that year. If, for example, they were born on Christmas and lived through January 3rd of the next year, you would be able to claim them as a dependant for both years.
Unfortunately for subsequent tax years you won't be able to claim your sweet baby as a dependant, so be sure you or your tax professional remember to remove them from your tax return. Also remember that you will need to provide their social security number for the tax return, and that usually takes a few weeks to arrive in the mail.
Insurance
Insurance is important if your baby was born with major medical issues and a NICU stay. If you have employer insurance and your live-born baby incurred significant medical bills under their name (i.e. NICU) it is highly recommended that you add them to your medical plan. Usually you need to do this within 30 days of the baby's birth date, and it doesn't matter if it's a family plan or employee+dependant plan (whatever your situation warrants). Then, for the month following their death you can remove them from the medical plan because they will no longer have medical bills that need to be covered by insurance. You might still receive medical bills months (if not years) after their death, unfortunately, but they should be filed under that insurance by the time you receive any subsequent bills, if any.
Note: There is no need to add your baby to your dental or vision plans unless their medical bills would be filed under those particular plans (the vast majority of cases it will only be medical bills, so only your medical plan).
Example: Gemma was born on 11/4/21 and died on 11/6/21. We added her to mom's insurance (employee+dependant) through work when we got home from the hospital the week after. This covered all of Gemma's NICU bills incurred starting on 11/4/21. All other hospital bills were under mom's name, regardless of the date of service, and would be covered under her insurance.
Then, on 12/1/21 she reached back out to her employer and notified them of Gemma's death and provided a copy of her death certificate as proof. This enabled us to remove Gemma's name from our medical premiums starting in December, so we only had to pay premiums for November pay periods (~$100). But by doing this it paid for over $50,000 in medical bills we would have otherwise had to pay.
If your baby was miscarried or stillborn they will not have any medical bills under their name since they were not considered a live birth, so there are no insurance changes you would need to make to your medical plan. If your baby was born after 20 weeks gestation or was stillborn it would still entitle you to maternity leave and thus, it would also still be considered the "birth of a baby" and be a "qualifying life event", should you need to make changes to your insurance plans, STD, LTD, or deductions. This might be helpful if you anticipate needing more time off of work, had a C-section, or had an extensive medical stay warranting that you switch to a medical plan that would cover your bills more (for example, switching from an HSA to a PPO plan for a smaller deductible but higher premiums, which is normally the cheapest option in a calendar year when you have a baby).
Always remember that what is considered a live birth (and point of viability) is dependant on state law, and sometimes hospital policy.