Yeah even though it sounds like you currently have more contact with the first and know more people invited, you can't not go to someone you've known for 10 years because of someone you've known for a year and a baby at that.
Send around something nice for the baby and go to the 40th.
I had my son's 1st birthday recently and quite a few people didn't attend. We kept it casual anyway, after all, what is a one year old gonna know? A few people who couldn't come sent cards and gifts or called us on his birthday. That was great.
Ok, I am going to go completely against the grain here and say if it was me, I would go to the 1st birthday. Reason being that I am an absoute textbook introvert and the thought of being at any party where I only know a couple of people literally terrifies me. I would go to the 1st birthday, and make a point of organising lunch with the person from the 40th a day or two later.
Attend the party where the guest of honor will be able to actually remember that you came along.
Send a lovely present to the one year old though. I suggest a book, one that you write a nice message inside the dust jacket of, that way no-one will even remember you didn't attend but for the life of the book it will be remembered that you acknowledged it!