Can I connect it to a sub panel that is rated for 70 amp? I just want to put 3 or 4 20 amp 120 breakers in. Is it safe to do it?
Yes, that's fine. The breaker in the main panel needs to protect the wiring to the subpanel.
Obviously, a 70A panel will not be damaged by 40A of power.
Just one word; don't penny-pinch when buying panels. Buy the biggest panel you possibly can, so you can add circuits later. A 40A/240V panel can support as many as 10 or more 120V/15A circuits, presuming they won't all be heavily loaded at the same time. You might even be able to upgrade the power feed later. Many panels are sold as 4 spaces/8 circuits. Don't count on the second one, given today's requirements for GFCI and AFCI which don't fit in half spaces.