I've been working at a voxel sandbox game and have already implemented chunk generation and stuff. But I just found that generating underground blocks with the surface ones is impossible, since that causes lag. My game only generates surface blocks for now. Are there any available chunk generation algorithms that covers the solution for my problem? Please give a link or clearly state the method. Thanks
Don't render unexposed blocks; only render those that are not entirely surrounded/covered by blocks. This includes surface blocks as well as the surface of caves in the underground.
There are more tips in this related answer: https://gamedev.stackexchange.com/a/32933/26250